'''
    自动存款系统模拟
    1.账户信息数据源
    2.登陆
    3.查询余额
    4.取钱
    5.存钱
    6.退出
    7.界面和交互
'''

# 1.账户信息数据源
account_list = [
    {'name':'zhangsan','account':'1001', 'password':'112233','amount':1000},
    {'name':'lisi','account':'1002','password':'223344','amount':2000},
    {'name':'zhaowu','account':'1003','password':'123456','amount':3000}
]

# 2.登陆
def log_in(count=0):

    account = input('请输入您的账户号码：')
    password = input('请输入您的密码：')

    for info in account_list:
        if info['account'] == account and info['password'] == password:
            print('登陆成功！')
            return info

    count += 1
    if count < 5:
        print('账户或密码无效，请重新输入，您还有{}次机会！'.format(5 - count))
        log_in(count)
    else:
        print('操作次数超过限制，禁止操作！')

# 3.查询余额
def show_amount(info):
    print('您的账户余额：{}元'.format(info['amount']))

# 4.存款
def save_amount(info):
    new_amount = int(input('请输入您要存入的金额(元)：'))
    info['amount'] += new_amount
    print('存款成功！您的账户余额：{}元'.format(info['amount']))

# 5.取款
def withdraw_amount(info):
    new_amount = int(input('请输入您要存入的金额(元)：'))
    info['amount'] -= new_amount
    print('存款成功！您的账户余额：{}元'.format(info['amount']))

# 6.退出
def log_out():
    pass

# 7.界面和交互
print('='*10,'欢迎进入自动存款系统！','='*10)
info=log_in()
print('='*40)

if info is not None:

    while True:
        print('{:1} {:13} {:15}'.format(' ', '1.余额', '2.存款'))
        print('{:1} {:13} {:15}'.format(' ', '3.取款', '4.退出'))
        print('='*40)
        key = input('请输入您要进行的操作：')

        if key == '1':
            show_amount(info)
            print('按回车继续')
            print('='*40)
        elif key == '2':
            save_amount(info)
            print('按回车继续')
            print('='*40)
        elif key == '3':
            withdraw_amount(info)
            print('按回车继续')
            print('='*40)
        elif key == '4':
            log_out()
            print('='*40)
            print('感谢使用！您已退出系统！欢迎再次使用！')
            break
        else:
            print('=' * 12, '操作无效', '=' * 12)